package net.timico.webservice;

import javax.jws.WebService;

import net.timico.messaging.auth.AuthLogin;

@WebService(endpointInterface = "net.timico.webservice.InfoConnexion")
public class InfoConnexionWS implements InfoConnexion {

	public String getServiceIP() {
		String ip = "localhost";
		
		return ip;
	}
	
	public ObjectAMQ connexionTopic(String nomSujet, String userName, String userId, String userPwd) {
		
		String urlAMQ = "tcp://"+InfoConnexionPublisher.getIPAddr()+":61616";
		
		if(!userName.isEmpty() && userId.isEmpty() && userPwd.isEmpty()) {
			ObjectAMQ object = AuthLogin.logNewUser(userName);
			object.setUrlAMQ(urlAMQ);
			return object;
		} 

		if(userName.isEmpty() && !userId.isEmpty() && !userPwd.isEmpty()) {
			ObjectAMQ object = AuthLogin.getAuthorizeID(userId, userPwd);
			object.setUrlAMQ(urlAMQ);
			return object;
		} 
		return new ObjectAMQ(null, null, false, null, null, null);

	}
}
 